Back to Transposition

Rail Fence Cipher (zigzag)

What is a Rail Fence Cipher (zigzag)?

Rail Fence cipher is a simple transposition cipher that writes the message in a zigzag pattern on a number of "rails" (horizontal lines), then reads off each rail to create the ciphertext. Despite its simplicity, it can effectively scramble text in a way that's not immediately obvious to read, though it's not considered cryptographically secure by modern standards.

Key Components:

   1. Number of rails (key)
   2. Message text
   3. Zigzag pattern
   4. Reading direction

Key Rules:

   1. Write text diagonally down and up
   2. Fill spaces in zigzag pattern
   3. Read text horizontally by rail
   4. Spaces are usually removed

Example with 3 rails:

Message: "HELLOWORLD"

   H                                                O                                                   L
         ↘                                  ↗           ↘                                      ↗          ↘
               E                      L                         W                         R                       D
                    ↘         ↗                                      ↘           ↗
                           L                                                   O
   
Result: "HELLOWORLD " → "HOLELWRDLO"

Video for explanation